//
//  YQBaseDefine.h
//  PensionDoctor
//
//  Created by tbb on 2019/6/28.
//  Copyright © 2019 YQ. All rights reserved.
//

#ifndef YQBaseDefine_h
#define YQBaseDefine_h

#define kYQREGISTERTABLEVIEWNIBCELL(name) [self.listTableView registerNib:[UINib nibWithNibName:name bundle:nil] forCellReuseIdentifier:name];
#define kYQREGISTERTABLEVIEWCELL(kClass) [self.listTableView registerClass:[kClass class] forCellReuseIdentifier:[NSString classToClassNameStr:[kClass class]]];

#define kYQREGISTERTABLEVIEWCNIBHeaderFooter(name) [self.listTableView registerNib:[UINib nibWithNibName:name bundle:nil] forHeaderFooterViewReuseIdentifier:name];
#define kYQREGISTERTABLEVIEWCHeaderFooter(kClass) [self.listTableView registerClass:[kClass class] forHeaderFooterViewReuseIdentifier:[NSString classToClassNameStr:[kClass class]]];


#define kYQPUSH(VC) [self.navigationController pushViewController:VC animated:true];

#define kFontWithSize(size)  [UIFont systemFontOfSize:size]

#define kSystemBold(size) [UIFont boldSystemFontOfSize:size]
#define kSystemMedium(size) [UIFont systemFontOfSize:size weight:(UIFontWeightMedium)]
#define MBErrHUD(A)  [MBProgressHUD showError:A];
#define MBSucHUD(A)  [MBProgressHUD showSuccess:A];
#define YQIMG(name) [UIImage imageNamed:name]
#define YQSTRINGTOURL(urlStr) [NSURL URLWithString:urlStr]

/*基于QMUI*/
/*加载菊花*/
#define YQSHOWLOADINGTIPS(str) [QMUITips showLoading:[NSString stringWithFormat:@"%@",str] inView:DefaultTipsParentView];
/*去掉提示层*/
#define YQHIDELOADINGTIPS [QMUITips hideAllTipsInView:DefaultTipsParentView];
//提示语言
#define YQUITIPSERROR(msg) [QMUITips showError:[NSString stringWithFormat:@"%@",msg]];
#define YQUITIPSSUCCEED(msg) [QMUITips showSucceed:[NSString stringWithFormat:@"%@",msg]];
//菊花没文字
#define YQSHOWLOADINGINVIEW [QMUITips showLoadingInView:DefaultTipsParentView];

#define kMBMesHUD(A)  [MBProgressHUD showMessage:A toView:self.view];
#define kMBHidHUD     [MBProgressHUD hideHUDForView:self.view animated:true];

//判断是否为空
#define IsNilOrNull(_ref)  (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) || ([(_ref) isEqual:@"null"]) || ([(_ref) isEqual:@"(null)"]))

#define IsStrEmpty(_ref)  (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) || ([(_ref) isEqualToString:@""]))

#define IsArrEmpty(_ref)  (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) || ([(_ref) count] == 0))

//网络错误
#define YJNetShowErrorText @"网络有误，请重试！"
//颜色定义
#define HexColor(hex) [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16)) / 255.0 green:((float)((hex & 0xFF00) >> 8)) / 255.0 blue:((float)(hex & 0xFF)) / 255.0 alpha:1]


#define HexColorA(hex,a) [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16)) / 255.0 green:((float)((hex & 0xFF00) >> 8)) / 255.0 blue:((float)(hex & 0xFF)) / 255.0 alpha:a]

#define RGB(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define RGBA(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
//字符串转URL
#define kStrToUrl(str) [NSURL URLWithString:str]
#define ws(type)  __weak typeof(type) weak##type = type;
#define ss(type)  __strong typeof(type) type = strong##type;
//GDC
//GCD - 一次性执行
#define kDISPATCH_ONCE_BLOCK(onceBlock) static dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock);

//GCD - 在Main线程上运行
#define kDISPATCH_MAIN_THREAD(mainQueueBlock) dispatch_async(dispatch_get_main_queue(), mainQueueBlock);

//GCD - 开启异步线程
#define kDISPATCH_GLOBAL_QUEUE_DEFAULT(globalQueueBlock) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlocl);
//系统版本
#define iOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
#define iOS9Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f)
#define iOS9_1Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.1f)
#define iOS10_1Later ([UIDevice currentDevice].systemVersion.floatValue >= 10.1f)
#define iOS11Later ([UIDevice currentDevice].systemVersion.floatValue >= 11.0f)
#define iOS12Later ([UIDevice currentDevice].systemVersion.floatValue >= 12.0f)
#define iOS13Later ([UIDevice currentDevice].systemVersion.floatValue >= 13.0f)
//屏幕适配相关定义
//iPhoneX
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125,2436), [[UIScreen mainScreen] currentMode].size) : NO)

#define kYQLS(key) NSLocalizedString(key, nil)

#define kYQPScreenWidth \
([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)] ? [UIScreen mainScreen].nativeBounds.size.width/[UIScreen mainScreen].nativeScale : [UIScreen mainScreen].bounds.size.width)
#define kYQPScreenHeight \
([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)] ? [UIScreen mainScreen].nativeBounds.size.height/[UIScreen mainScreen].nativeScale : [UIScreen mainScreen].bounds.size.height)
#define kYQScreenSize \
([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)] ? CGSizeMake([UIScreen mainScreen].nativeBounds.size.width/[UIScreen mainScreen].nativeScale,[UIScreen mainScreen].nativeBounds.size.height/[UIScreen mainScreen].nativeScale) : [UIScreen mainScreen].bounds.size)

#define kUserDefaults [NSUserDefaults standardUserDefaults]
#define kStatusbarHeight iPhoneX ? 44.f : 20.f

#define WZ_StatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height // 状态栏高度
#define WZ_NavBarHeight 44.0
//#define WZ_TabBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height>20?83:49) // 底部tabbar高度
#define WZTopNavH (WZ_StatusBarHeight + WZ_NavBarHeight) // 整个导航栏高度

#define kDevice_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

#define is_iPhoneX [UIScreen mainScreen].bounds.size.height == 812.0 ? YES:NO
#define is_iPhonePlus [UIScreen mainScreen].bounds.size.width == 414 ? YES:NO
#define is_iPhoneLittle [UIScreen mainScreen].bounds.size.width == 320 ? YES:NO

//new
// 判断是否是ipad
#define isPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
// 判断iPhone4系列
#define kiPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
// 判断iPhone5系列
#define kiPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
// 判断iPhone6系列
#define kiPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
//判断iphone6+系列
#define kiPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
// 判断iPhoneX
#define IS_IPHONE_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
// 判断iPHoneXr
#define IS_IPHONE_Xr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
// 判断iPhoneXs
#define IS_IPHONE_Xs ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
// 判断iPhoneXs Max
#define IS_IPHONE_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)

#define Height_StatusBar ((IS_IPHONE_X == YES || IS_IPHONE_Xr == YES || IS_IPHONE_Xs == YES || IS_IPHONE_Xs_Max == YES) ? 44.0 : 20.0)
#define Height_NavBar ((IS_IPHONE_X == YES || IS_IPHONE_Xr == YES || IS_IPHONE_Xs == YES || IS_IPHONE_Xs_Max == YES) ? 88.0 : 64.0)
#define Height_TabBar ((IS_IPHONE_X == YES || IS_IPHONE_Xr == YES || IS_IPHONE_Xs == YES || IS_IPHONE_Xs_Max == YES) ? 83.0 : 49.0)

#define kHeight_Botton_SafeArea ((IS_IPHONE_X == YES || IS_IPHONE_Xr == YES || IS_IPHONE_Xs == YES || IS_IPHONE_Xs_Max == YES) ? 34 : 0)

#define kHeight_Top_SafeArea ((IS_IPHONE_X == YES || IS_IPHONE_Xr == YES || IS_IPHONE_Xs == YES || IS_IPHONE_Xs_Max == YES) ? 44 : 0)

//屏幕适配相关定义 end
#define KSRatio kYQPScreenWidth/375.0
//字体适配
//1.在PCH文件中定义宏,方便调用,调用UIFont的分类方法
#define IMAGE_NAMED(name) [UIImage imageNamed:name]

#define FontSizeCaseOne(size) [UIFont fit_configureWithScreenWidith:(size)]

//字体适配 end
#endif /* YQBaseDefine_h */
